<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>后台管理</title>
    <link rel="stylesheet" href="../layui/css/layui.css">
    <link rel="stylesheet" href="../css/admin.css">
</head>

<body class="layui-layout-body">
    <div class="layui-layout layui-layout-admin">
        <div class="layui-header header">
            <a href="index.html">
                <div class="layui-logo logo">后台管理
                </div>
            </a>
            <!-- 头部区域（可配合layui已有的水平导航） -->

            <ul class="layui-nav layui-layout-right">
                <li class="layui-nav-item diy-nav">
                    <a href="javascript:;">
                        <img src="http://t.cn/RCzsdCq" class="layui-nav-img"> 贤心
                    </a>
                    <dl class="layui-nav-child">
                        <dd><a href="basic.html">基本资料</a></dd>
                        <dd><a href="modifypwd.html">安全设置</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item diy-nav"><a href="">注销</a></li>
            </ul>
        </div>

        <div class="layui-side layui-bg-black">
            <div class="layui-side-scroll">
                <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
                <ul class="layui-nav layui-nav-tree layui-bg-black" lay-filter="test">
                    <li class="layui-nav-item layui-nav-itemed ">
                        <a class="" href="javascript:;"><i class="layui-icon layui-icon-user"> </i>用户</a>
                        <dl class="layui-nav-child">
                            <dd class="layui-this"><a class="tabs" href="userManage.html" data-id="33">用户管理</a></dd>
                            <dd><a class="tabs" href="adminManage.html">管理员管理</a></dd>
                        </dl>
                    </li>
                    <li class="layui-nav-item ">
                        <a href="javascript:;"><i class="layui-icon layui-icon-set-sm"> </i>设置</a>
                        <dl class="layui-nav-child">
                            <dd class=""><a href="setting.html">网站设置</a></dd>
                            <dd><a href="link.html">友情链接</a></dd>
                        </dl>
                    </li>
                    <li class="layui-nav-item"><a href="#"><i class="layui-icon layui-icon-about"> </i>内容管理</a>
                        <dl class="layui-nav-child">
                            <dd><a href="type.html">分类管理</a></dd>
                            <dd><a href="list.html">帖子列表</a></dd>
                        </dl>
                    </li>
                </ul>
            </div>
        </div>

        <div class="layui-body">
            <!-- 内容主体区域 -->
            <div class="layui-card">
                <div class="layui-card-body">
                    <div class="layui-breadcrumb">
                        <a href="index.html">首页</a>
                        <a href="#">用户</a>
                        <a href="userManage.html">用户管理</a>
                    </div>
                </div>
            </div>
            <div class="layui-fluid">
                <div class="layui-card">
                    <div class="layui-form layui-card-header">
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label for="" class="layui-form-label">用户名</label>
                            </div>
                            <div class="layui-inline">
                                <input type="text" class="layui-input" requiredname="username" placeholder="请输入用户名">
                            </div>
                            <div class="layui-inline">
                                <label for="" class="layui-form-label">邮箱</label>
                            </div>
                            <div class="layui-inline">
                                <input type="text" class="layui-input" required required="email" name="email" placeholder="请输入邮箱">
                            </div>
                            <div class="layui-inline">
                                <button class="layui-btn" lay-submit><i class="layui-icon layui-icon-search"></i></button>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-card">
                    <div style="padding-bottom:10px;" class="layui-btn-group demoTable">
                        <button class="layui-btn" data-type="del">删除</button>
                        <button class="layui-btn" data-type="add">添加</button>
                    </div>

                    <table class="layui-hide" id="user" lay-filter="user"></table>
                </div>
            </div>
        </div>

        <div class="layui-footer ">
            <!-- 底部固定区域 -->
            © layui.com - 底部固定区域
        </div>
    </div>
    <script src="../layui/layui.js "></script>
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js "></script>
    <style>
        .cardInfo {
            font-size: 36px;
            color: #666;
            line-height: 36px;
            padding: 5px 0 10px;
            overflow: hidden;
            text-overflow: ellipsis;
            word-break: break-all;
            white-space: nowrap;
        }
    </style>

    <script type="text/html" id="barDemo">
        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </script>
    <script>
        //JavaScript代码区域

        layui.use(['element', 'table'], function() {
            var element = layui.element;
            var table = layui.table;

            table.render({
                elem: "#user ",
                url: '#',
                cols: [
                    [{
                        type: 'checkbox',
                        flexd: 'left'
                    }, {
                        field: 'id',
                        width: 180,
                        title: 'ID'
                    }, {
                        field: 'username',
                        width: 180,
                        title: "用户名 "
                    }, {
                        field: 'email',
                        width: 180,
                        title: "邮箱 "
                    }, {
                        field: 'ip',
                        width: 180,
                        title: "IP"
                    }, {
                        field: 'time',
                        width: 180,
                        title: "加入时间"
                    }, {
                        field: 'count',
                        width: 180,
                        title: "登陆次数"
                    }, {
                        fixed: 'right',
                        title: '操作',
                        toolbar: '#barDemo',
                    }]
                ],
                page: true
            });
            //复选框
            table.on('checkbox(user)', function(obj) {
                console.log(obj);
            });
            //操作行
            table.on('tool(user)', function(obj) {
                var data = obj.data;
                if (obj.event === "edit") {
                    layer.msg('编辑事件')
                } else if (obj.event === "del") {
                    layer.msg('删除事件')
                }
            });
            //上面按钮
            var $ = layui.$,
                active = {
                    del: function() {
                        layer.msg('删除事件');
                    },
                    add: function() {
                        layer.open({
                            title: '',
                            type: 2,
                            closeBtn: 1,
                            content: "userAdd.html",
                            offset: 'auto',
                            area: ['400px', '400px'],
                            scroll: false
                        });
                    }
                };
            $('.demoTable .layui-btn').on('click', function() {
                var type = $(this).data('type');
                active[type] ? active[type].call(this) : '';
            });
        });
    </script>
</body>

</html>